//
//  Nrootview.m
//  ZLShang
//
//  Created by wangguangming on 16/1/23.
//  Copyright © 2016年 Amber. All rights reserved.
//

#import "Nrootview.h"
#import "Base.h"
#import "ViewController.h"
@implementation Nrootview
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
        {
        self.backgroundColor=COLOR;
        [self addallview];
        }
    return self;
}
-(void)addallview{

    UIScrollView *scroller=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT)];
    scroller.userInteractionEnabled=YES;
    scroller.backgroundColor=COLOR;
    [self addSubview:scroller];
    NSArray *nameArr=@[@"待配货订单",@"为发货订单",@"已配货订单",@"已取消订单",@"发货记录",@"所有问题件"];
    NSArray *imageArr=@[@"home1.png",@"home2.png",@"home3.png",@"home4.png",@"home5.png",@"home6.png"];
    for (int i=0; i<6; i++) 
    {
    self.itemView=[[UIButton alloc] initWithFrame:CGRectMake((i%2)*(WIDTH/2-3)+6,(i/2)*(WIDTH/2-3)+6 , WIDTH/2-9, WIDTH/2-9)];
    self.itemView.backgroundColor=[UIColor whiteColor];
    self.itemView.tag=110+i;
    self.itemView.layer.cornerRadius=4;
    [self setimagesforView:self.itemView name:nameArr[i] image:imageArr[i]];
    [scroller addSubview:self.itemView];
    
       }
    
    scroller.contentSize=CGSizeMake(0, 3*(WIDTH/2-3)+6);
    self.menuTable=[[UITableView alloc] initWithFrame:CGRectMake(0, 64, 0, HEIGHT-64)];
    [self addSubview:self.menuTable];

}
-(void)setimagesforView:(UIButton *)view name:(NSString *)nameString image:(NSString *)imgString{
    
    UIImageView *imagev=[[UIImageView alloc] initWithFrame:CGRectMake(15, 0, view.frame.size.width-30, view.frame.size.width-30)];
    imagev.image=[UIImage imageNamed:imgString];
    UILabel *nameLab=[[UILabel alloc] initWithFrame:CGRectMake(15, view.frame.size.width-30, view.frame.size.width-30, 30)];
    nameLab.text=nameString;
    nameLab.textColor=[UIColor grayColor];
    nameLab.textAlignment=NSTextAlignmentCenter;
    [view addSubview:imagev];
    [view addSubview:nameLab];
    
   
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
